<?php

namespace App\Api\Controllers;

use App\Api\Dao\UserRechargeDao;
use App\Api\Logic\UserRechargeLogic;
use App\Exceptions\ValidationException;
use Illuminate\Http\Request;

class UserRechargeController extends BaseController
{
    /**
     * 创建用户充值订单
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws ValidationException
     */
    public function createUserRecharge(Request $request,UserRechargeLogic $userRechargeLogic,UserRechargeDao $userRechargeDao){
        $data = array_merge(['u_id'=>$request->u_id],$request->all());
        $userRechargeLogic->createUserRecharge($data);
        $result = $userRechargeDao->createUserRecharge($data);
        return $this->success($result);
    }

    /**
     * 获取充值订单详情
     * @return \Illuminate\Http\JsonResponse
     * @throws ValidationException
     */
    public function getUserRechargeInfo(Request $request,UserRechargeLogic $userRechargeLogic,UserRechargeDao $userRechargeDao){
        $data = array_merge(['u_id'=>$request->u_id],$request->all());
        $userRechargeLogic->getUserRechargeInfo($data);
        $result = $userRechargeDao->getUserRechargeInfo($data);
        return $this->success($result);
    }
}
